lexer grammar BlipLexer;

@members {
  public Collection<Problem> problems = new ArrayList<Problem>();

      public void displayRecognitionError(String[] tokenNames,
                                        RecognitionException e) {
          Problem problem = MocaFactory.eINSTANCE.createProblem();
          int line  = e.line;
          int charPos = e.charPositionInLine;
          int tokenLenght = 1;
          Token token = e.token;
          if(token != null) 
            tokenLenght = token.getText().length();
                  
          
          problem.setType(ProblemType.ERROR);
          problem.setLine(line); 
          problem.setCharacterPositionStart(charPos); 
          problem.setCharacterPositionEnd(charPos+tokenLenght);
          problem.setMessage("Lexer: " + getErrorMessage(e, tokenNames)); 
          
          problems.add(problem);
          super.displayRecognitionError(tokenNames, e);
    }
}

@header {
package org.moflon.moca.blip.parser;
import java.util.Collection;
import Moca.MocaFactory;
import Moca.Problem;
import Moca.ProblemType;
}

// Lexer Rules:
SLASH : '/';

COLON : ':';

AT : '@';

MINUS: '-';

LBRACE: '{';

RBRACE: '}';

BRACKETS: '[]';

COMMA: ',';


// Special Token Definitions
SERVICETYPE: 'NATIVE' | 'STORAGE' | 'REST';

// Common Token Definitions
fragment CR:    '\r';
fragment LF:    '\n';
fragment SPACE:    ' ';
fragment TAB:    '\t';

fragment LETTER:    'a' .. 'z' | 'A' .. 'Z';
fragment DIGIT:    '0' .. '9';
STRING: ('_' | LETTER | DIGIT | '.')+;
WS : (' ' | '\t' | '\f' | '\n' | '\r')+ {skip();};
COMMENT: '//' .* '\n' {skip();};

